<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>flooper2</title>
    <link rel="stylesheet" type="text/css" href="csound.css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.78.1" />
    <link rel="home" href="index.html" title="The Canonical Csound Reference Manual" />
    <link rel="up" href="OpcodesTop.html" title="Orchestra Opcodes and Operators" />
    <link rel="prev" href="flooper.html" title="flooper" />
    <link rel="next" href="floor.html" title="floor" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">flooper2</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="flooper.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="floor.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry">
      <a id="flooper2"></a>
      <div class="titlepage"></div>
      <a id="Indexflooper2" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">flooper2</span>
        </h2>
        <p>flooper2 — 
      Function-table-based crossfading looper.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp105228752"></a>
        <h2>Description</h2>
        <p>
   This opcode implements a crossfading looper with variable loop parameters and three
  looping modes, optionally using a table for its crossfade shape. It accepts 
  non-power-of-two tables for its source sounds, such as deferred-allocation
   GEN01 tables, with one or two channels.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp105230240"></a>
        <h2>Syntax</h2>
        <pre class="synopsis">asig1[,asig2] <span class="command"><strong>flooper2</strong></span> kamp, kpitch, kloopstart, kloopend, kcrossfade, ifn \
      [, istart, imode, ifenv, iskip]</pre>
      </div>
      <div class="refsect1">
        <a id="idp105303840"></a>
        <h2>Initialization</h2>
        <p>
      <span class="emphasis"><em>ifn </em></span> -- sound source function table number, generally created using GEN01
    </p>
        <p>
      <span class="emphasis"><em>istart </em></span> -- playback start pos in seconds
    </p>
        <p>
      <span class="emphasis"><em>imode </em></span> -- loop modes: 0 forward, 1 backward, 2 back-and-forth [def: 0]
    </p>
        <p>
      <span class="emphasis"><em>ifenv </em></span> -- if non-zero, crossfade envelope shape table number. The default, 0, sets
the crossfade to linear.
    </p>
        <p>
      <span class="emphasis"><em>iskip </em></span> -- if 1, the opcode initialisation is skipped, for tied notes, performance
continues from the position in the loop where the previous note stopped. The default, 0, does not skip
initialisation
    </p>
      </div>
      <div class="refsect1">
        <a id="idp105309120"></a>
        <h2>Performance</h2>
        <p>
      <span class="emphasis"><em>asig1[, asig2]</em></span> -- output sig (mono or stereo).
    </p>
        <p>
      <span class="emphasis"><em>kamp</em></span> -- amplitude control </p>
        <p>
      <span class="emphasis"><em>kpitch</em></span> -- pitch control (transposition ratio); negative values are not allowed.
    </p>
        <p>
      <span class="emphasis"><em>kloopstart</em></span> -- loop start point (secs). Note that although k-rate, loop parameters
such as this are only updated once per loop cycle.
</p>
        <p>
      <span class="emphasis"><em>kloopend</em></span> -- loop end point (secs), updated once per loop cycle.
</p>
        <p>
      <span class="emphasis"><em>kcrossfade </em></span> -- crossfade length (secs), updated once per loop cycle and limited to
loop length.</p>
        <p>
      Mode 1 for <span class="emphasis"><em>imode </em></span> will only loop backwards from the end point to the start point.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp105316128"></a>
        <h2>Examples</h2>
        <p>
      </p>
        <div class="example">
          <a id="idp105317056"></a>
          <p class="title">
            <strong>Example 274. </strong>
          </p>
          <div class="example-contents">
            <pre class="programlisting">
aout <span class="opc">flooper2</span> 16000, 1, 1, 5, 0.05, 1  <span class="comment">; loop starts at 1 sec, for 4 secs, 0.05 crossfade</span>
     <span class="opc">out</span>      aout</pre>
          </div>
        </div>
        <p><br class="example-break" />
    </p>
        <p>
The example above shows the basic operation of <span class="emphasis"><em>flooper2</em></span>. Pitch can
be controlled at the k-rate, as well as amplitude and loop parameters. 
The example assumes
table 1 to contain at least 5.05 seconds of audio (4 secs loop duration,
starting 1 sec into the table, using 0.05 secs after the loop end for the
crossfade). Looping is in mode 0 (normal forward loop).
    </p>
        <p>
      Here is another example of the flooper2 opcode. It uses the file <a class="ulink" href="examples/flooper2.csd" target="_top"><em class="citetitle">flooper2.csd</em></a> and <a class="ulink" href="examples/fox.wav" target="_top"><em class="citetitle">fox.wav</em></a>.
      </p>
        <div class="example">
          <a id="idp105323568"></a>
          <p class="title">
            <strong>Example 275. </strong>
          </p>
          <div class="example-contents">
            <p>See the sections <a class="link" href="UsingRealTime.html" title="Real-Time Audio"><em class="citetitle">Real-time Audio</em></a> and <a class="link" href="CommandFlags.html" title="Csound command line"><em class="citetitle">Command Line Flags</em></a> for more information on using command line flags.</p>
            <pre class="programlisting">
<span class="csdtag">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</span>
<span class="comment">; Select audio/midi flags here according to platform</span>
-odac     <span class="comment">;;;realtime audio out</span>
<span class="comment">;-iadc    ;;;uncomment -iadc if realtime audio input is needed too</span>
<span class="comment">; For Non-realtime ouput leave only the line below:</span>
<span class="comment">; -o flooper2.wav -W ;;; for file output any platform</span>
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</span>

<span class="ohdr">sr</span> <span class="op">=</span> 44100
<span class="ohdr">ksmps</span> <span class="op">=</span> 32
<span class="ohdr">nchnls</span> <span class="op">=</span> 2
<span class="ohdr">0dbfs</span>  <span class="op">=</span> 1

<span class="oblock">instr</span> 1
<span class="comment">; looping back and forth,  0.05 crossfade </span>
kst  <span class="opc">line</span>     .2, p3, 2 <span class="comment">;vary loopstartpoint</span>
aout <span class="opc">flooper2</span> .8, 1, 0, kst, 0.05, 1, 0, 2  
     <span class="opc">outs</span>     aout, aout

<span class="oblock">endin</span>
<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>
<span class="comment">; Its table size is deferred,</span>
<span class="comment">; and format taken from the soundfile header</span>
<span class="stamnt">f</span> 1 0 0 1 "<span class="stamnt">f</span>ox.wav" 0 0 0

<span class="stamnt">i</span> 1 0 12
<span class="stamnt">e</span>
<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />
    </p>
      </div>
      <div class="refsect1">
        <a id="idp105327424"></a>
        <h2>Credits</h2>
        <p>
      </p>
        <table border="0" summary="Simple list" class="simplelist">
          <tr>
            <td>Author: Victor Lazzarini</td>
          </tr>
          <tr>
            <td>July 2006 </td>
          </tr>
        </table>
        <p>
    </p>
        <p>New plugin in version 5</p>
        <p>July 2006.</p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="flooper.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="OpcodesTop.html">Up</a>
          </td>
          <td width="40%" align="right"> <a accesskey="n" href="floor.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">flooper </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> floor</td>
        </tr>
      </table>
    </div>
  </body>
</html>
